# Maintainer: 3mb3dw0rk5 <3mb3dw0rk5 at gmail dot com>
# PKGBUILD derived from original AUR PKGBUILD
# Contributor: SpepS <dreamspepser at yahoo dot it>, eric <eric@archlinux.org>

pkgname=hexcurse
pkgver=1.60.0
pkgrel=1
pkgdesc="Versatile ncurses-based hex editor."
arch=('i686' 'x86_64')
#url="https://directory.fsf.org/project/HexCurse/"
url="https://github.com/LonnyGomes/hexcurse"
license=('GPL')
depends=('ncurses')
options=('!makeflags')
source=("${pkgname}-${pkgver}.tgz::https://github.com/LonnyGomes/hexcurse/archive/v${pkgver}.tar.gz"
        hexcurse-1.60.0-msys2-automake-version.diff
        hexcurse-1.60.0-msys2-getopt.diff
        hexcurse-1.60.0-gcc7.patch)
sha256sums=('f6919e4a824ee354f003f0c42e4c4cef98a93aa7e3aa449caedd13f9a2db5530'
            'f158c7034b15333808053a4988bd34ed3396f57328f9579cb9e94549a6b95659'
            '011f257f66bdeda280815fc0a31cdcf41f94a45bbd26c2789fc5f8ae883b96ae'
            '9f55c908acb9312c21d3f77c07f4e3dad7dc257802c9ada9b30c496576bda131')

# Helper macros to help make tasks easier #
apply_patch_with_msg() {
  for _fname in "$@"
  do
    msg2 "Applying ${_fname}"
    patch -Nbp1 -i "${srcdir}"/${_fname}
  done
}

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  apply_patch_with_msg \
    hexcurse-1.60.0-msys2-automake-version.diff \
    hexcurse-1.60.0-msys2-getopt.diff \
    hexcurse-1.60.0-gcc7.patch
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  ./configure \
    --build=${CHOST} \
    --host=${CHOST} \
    --target=${CHOST} \
    --prefix=/usr \
    --mandir=/usr/share/man

  make
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}/" install
}
